<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
    <%@ page import="no.ntnu.tdt4237.*" %>
    <%@page import="no.ntnu.tdt4237.helperactions.*"%>
    <%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<tags:header></tags:header>

<body>

<%

if(request.getParameter("RecoverPassword") != null) {
	//TODO: Terje implements this
	boolean success = false; //Fix this
	
	success = Database.resetPassword(request.getParameter("username"), request.getParameter("email"));
	
	if (success) {
		%>
		<tags:message message="Resetting password successful. Check your email!"></tags:message>
		<a href="login.jsp">Login</a>
		<%
	}
	else {
		%>
		Resetting password unsuccessful. Try again.
		<form action="" method="post">
		login: <input type="text" name="username"/><br />
		E-Mail:<input type="text" name="email"/><br />
		<input type="submit" name="RecoverPassword" value="RecoverPassword"/>
		</form>
		<%		
	}
}
else {
%>
<form action="" method="post">
		Login: <input type="text" name="username"/><br />
		E-Mail:	<input type="text" name="email"/><br />
	<input type="submit" name="RecoverPassword" value="RecoverPassword"/>
</form>
<%
}
%>

</body>
</html>